# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: omni <omni+alpine@hack.org>
pkgname=qutebrowser
pkgver=3.1.0
pkgrel=1
pkgdesc="Keyboard-driven, vim-like browser based on Python and Qt"
url="https://qutebrowser.org/"
# s390x, ppc64le and riscv64 blocked by qt5/qt6-qtwebengine
# armhf blocked by qt5-qtdeclarative -> py3-qt5
arch="noarch !armhf !s390x !ppc64le !riscv64"
license="GPL-3.0-only"
depends="
	py3-adblock
	py3-jinja2
	py3-pygments
	py3-yaml
	py3-tldextract
	"
makedepends="
	asciidoc
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-hypothesis
	py3-pytest
	py3-pytest-benchmark
	py3-pytest-mock
	py3-pytest-rerunfailures
	"
subpackages="$pkgname-doc $pkgname-pyc"
source="https://github.com/qutebrowser/qutebrowser/releases/download/v$pkgver/qutebrowser-$pkgver.tar.gz
	gpep517-install.patch
	"
options="!check" # missing pytest dependencies

# 32b arm not supported by qt6-qtwebengine
case "$CARCH" in
arm*)
	depends="$depends
		py3-qt5
		py3-pyqt5-sip
		py3-qtwebengine
		qt5-qtbase-sqlite
		qt5-qtwebengine
		"
		;;
*)
	depends="$depends
		py3-qt6
		py3-pyqt6-sip
		py3-pyqt6-webengine
		qt6-qtbase-sqlite
		qt6-qtwebengine
		"
		;;
esac

build() {
	a2x -f manpage doc/qutebrowser.1.asciidoc
	gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	make -f misc/Makefile DESTDIR="$pkgdir" PREFIX=/usr install
}

sha512sums="
79dff3cf4ff93c75150e5cb9ada835ed5faf0343f03854266c6138fb8e6cceb921c868e1e408432da61b85ebe37e7e1657f634771ff73f1395d1b6e169138d98  qutebrowser-3.1.0.tar.gz
2b60990691d09eb1df6c8a0d4212f51303fd5167378258f5d3fc19d6f07867c4c7e02248e0979c3a1c38fb5fa948345abee6b7af384e7ff1569b1f8a5ac8b8a9  gpep517-install.patch
"
